<template>
  <div>
    <van-nav-bar title="clipboard.js示例" class="nav-bar" left-arrow @click-left="navToBack"/>
    <div class="content">
      <div class="block">
        <van-row>
          <van-button type="info" data-clipboard-action="copy" :data-clipboard-text="'复制的文本'" class="clipboard" @click="copyInfo()">复制到剪切板</van-button>
        </van-row>
      </div>
    </div>
  </div>
</template>
<script>
import common from '@/mixins/common'
import Clipboard from 'clipboard'
import 'moment/locale/zh-cn'
export default {
  mixins: [common],
  methods: {
    // 复制
    copyInfo (value) {
      const clipboard = new Clipboard('.clipboard')
      clipboard.on('success', function () {
        console.log('已复制到剪切板')
      })
      clipboard.on('error', function () {
        console.log('复制失败')
      })
    }
  }
}
</script>
